<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑菜单</title>
    <link rel="stylesheet" type="text/css" href="/static/h+/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/h+/css/font-awesome.min93e3.css?v=4.4.0">
    <!-- Data Tables -->
    <link rel="stylesheet" type="text/css" href="/static/h+/css/plugins/iCheck/custom.css">
    <link rel="stylesheet" type="text/css" href="/static/h+/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/h+/css/style.min.css?v=4.1.0">
    <link rel="stylesheet" type="text/css" href="/static/layer/skin/layer.css">
    <style type="text/css">
        .form-control{width: 200px;}
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-title">
          <h5>编辑菜单</h5>
        </div>
        <div class="ibox-content">
          <form class="form-horizontal" onsubmit="return false">
            <div class="form-group">
              <label class="col-sm-2 control-label">标识</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="identity" value="{$menu.identity}">
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <label class="col-sm-2 control-label">名称</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="title" value="{$menu.title}">
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <label class="col-sm-2 control-label">链接</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="url" value="{$menu.url}">
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <label class="col-sm-2 control-label">排序</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" id="sort" value="{$menu.sort}">
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <label class="col-sm-2 control-label">是否显示</label>
              <div class="col-sm-10">
                <div class="radio i-checks">
                  <label><input type="radio" value="0" {if(!$menu.is_hide)}checked="checked" {/if}name="is_hide"><i></i>显示</label>
                  <label><input type="radio" value="1" {if($menu.is_hide)}checked="checked" {/if}name="is_hide"><i></i>隐藏</label>
                </div>
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <div class="col-sm-4 col-sm-offset-2">
                <input class="btn btn-primary" type="button" id="save" value="保存内容">
                <input class="btn btn-white" type="button" id="cancel" value="取消">
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
</body>
<script type="text/javascript" src="/static/h+/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/h+/js/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript" src="/static/layer/layer.js"></script>
<script type="text/javascript">
    $(function(){
        $('#cancel').click(function(){
            location.href = '/menu/lists';
        });
        $('#save').click(function(){
            var identity = $('#identity'), title = $('#title'), url = $('#url'), sort = $('#sort');
            if (identity.val() == '') {
                layer.msg('标识不能为空', {icon: 5, time: 1000}, function(){
                    identity.focus()
                });
                return false
            }
            if (title.val() == '') {
                layer.msg('菜单名称不能为空', {icon: 5, time: 1000}, function(){
                    title.focus()
                });
                return false
            }
            if ({$menu.pid} != 0 && url.val() == '') {
                layer.msg('链接不能为空', {icon: 5, time: 1000}, function(){
                    url.focus()
                });
                return false
            }
            if (sort.val() == '') {
                layer.msg('排序不能为空', {icon: 5, time: 1000}, function(){
                    sort.focus()
                });
                return false
            }
            $.ajax({
                type: 'post', cache: false, dataType: 'json',
                url: '/menu/edit',
                data: {'id': {$menu.id}, 'identity': identity.val(), 'title': title.val(), 'url': url.val(), 'sort': sort.val(), 'is_hide': $('input[name="is_hide"]:checked').val()},
                success: function(data){
                    if (data.status == 0) {
                        layer.msg(data.info, {icon: 6, time: 1000}, function(){
                            location.href = '/menu/lists';
                        });
                    }else{
                        layer.msg(data.info, {icon: 5, time: 1000});
                    }
                }
            })
        });
    });
</script>
</html>